package com.liuqi.knet.remoting.transport;

import com.liuqi.knet.remoting.Channel;
import com.liuqi.knet.remoting.ChannelHandler;
import com.liuqi.knet.remoting.RemotingException;

/**
 * @author liuqi
 * @date 2024/12/17 17:34
 **/
public abstract class AbstractChannelHandlerDelegate implements ChannelHandlerDelegate {

    protected final ChannelHandler handler;

    public AbstractChannelHandlerDelegate(ChannelHandler handler) {
        this.handler = handler;
    }

    @Override
    public ChannelHandler getHandler() {
        return handler;
    }

    @Override
    public void connected(Channel channel) throws RemotingException {
        handler.connected(channel);
    }

    @Override
    public void disconnected(Channel channel) throws RemotingException {
        handler.disconnected(channel);
    }

    @Override
    public void send(Channel channel, Object message) throws RemotingException {
        handler.send(channel, message);
    }

    @Override
    public void received(Channel channel, Object message) throws RemotingException {
        handler.received(channel, message);
    }

    @Override
    public void caught(Channel channel, Throwable exception) throws RemotingException {
        handler.caught(channel, exception);
    }

}
